

use Data/sample_income_discountoc_angle.dta, clear

	drop hour_*

	gen net_import= import-export
	** pre discounted price
	gen price = peakoffpeak_base
	
	replace price = FIT_price if net_import <=0
	
	egen cut_PV = cut(PV_production), at(0(0.5)6)


	egen cut_netimport= cut(net_import), at(-6(0.5)15)
	keep if hour >=8 & hour<=17


	gen ones =1


	replace FIT_type = "T" if FIT_type =="S"

		replace virtualincome = virtualincome/100

	collapse (mean) FIT_price price virtualincome pexport_FIT pimport_price (sum) Ngroup = ones , by(cut_PV FIT_type)

	drop if cut_PV >=5
	
	graph drop _all
	
	

	twoway (scatter price cut_PV  [w=Ngroup] if FIT_type =="P" , mcolor(gs0)  msymbol(circle) ) ///
	(scatter price cut_PV  [w=Ngroup]  if FIT_type =="T", mcolor(gs9)  msymbol(circle) ) ///
	(scatter price cut_PV  [w=Ngroup]  if FIT_type =="F", mcolor(gs0)  msymbol(circle_hollow) ) ///
	, legend(order(1 "60 FIT" 2 "1:1 & 25 FIT" 3 "8 FIT" ) region(style(none) lcolor(none)) cols(3)) yscale(range(10(10)60)) ///
	 ylabel(0(10)60,  angle(horizontal)) xscale(range(-0.2 5)) xlabel(0(1)5, labsize(large)) ytitle("p{subscript:ihd} (c/kWh)", size(large)) xtitle("Solar production (kWh)", size(large)) ///
	 scheme(s2mono) graphregion(color(white)) name(price) title(Panel A. Price , position(11) size(large) ring(7))


	
	
	
	
	twoway (scatter virtualincome cut_PV  [w=Ngroup] if FIT_type =="P" , mcolor(gs0)  msymbol(circle) ) ///
	(scatter virtualincome cut_PV  [w=Ngroup]  if FIT_type =="T", mcolor(gs9)  msymbol(circle) ) ///
	(scatter virtualincome cut_PV  [w=Ngroup]  if FIT_type =="F", mcolor(gs0)  msymbol(circle_hollow) ) ///
	, legend(order(1 "60 FIT" 2 "1:1 & 25 FIT" 3 "8 FIT" ) region(style(none) lcolor(none)) cols(3) size(large)) ///
	 xscale(range(-0.2 5)) xlabel(0(1)5, labsize(large)) ytitle("m{subscript:ihd} ($/hour)", size(large)) xtitle("Solar production (kWh)", size(large)) ///
	 scheme(s2mono) graphregion(color(white)) name(inc) title(Panel B. Solar income , position(11) size(large) ring(7))
	
	
	grc1leg oc inc , xsize(3) ysize(1) 
	
	graph export Results/Andrea/oc_inc_IV.pdf, replace

	
	
	grc1leg price inc , xsize(3) ysize(1) 
	
	graph export Results/Andrea/price_inc_IV.pdf, replace

	
	
	
